<template>
    <el-aside style="margin-top:100px;width: 59px;height:600px;text-align: center; background-color: #2e2e2e;max-height: 600px;overflow-x: hidden;
        overflow-y: scroll;
      " class="setting">
      <div class="myavatar"  @click="dialogTableVisible = true">
        <img :src="user.avatar" />
      </div>
      <el-dialog width="400px" heiht="600px" :visible.sync="dialogTableVisible">
          <UserCard/>
      </el-dialog>
      <ul class="setting-list">
        <li class="setting-list-item" v-for="item in settingList" :key="item.name" @click="settingChoose(item.name)">
          <img :src="settingChecked == item.name ? item.icon_yes : item.icon_no" />
        </li>
      </ul>
    </el-aside>    
</template>

<script>
import { getInfo } from "@/api/user";
import UserCard from "./UserCard.vue";
import { getToken } from "@/utils/auth";

export default {
  name: "Setting",
  components: { UserCard },
  data() {
    return {
      user: {},
      dialogTableVisible: false,
      settingChecked: "消息",
      settingList: [
        {
          name: "消息",
          icon_yes: "https://api.xmj123.top:8888/down/hr8A9Qb1wEBE.png",
          icon_no: "https://api.xmj123.top:8888/down/lLhC8ovh8htA.png",
        },
        {
          name: "通讯录",
          icon_yes: "https://api.xmj123.top:8888/down/YzWttpLS6lga.png",
          icon_no: "https://api.xmj123.top:8888/down/DUeDajTuyA15.png",
        },
        {
          name: "收藏",
          icon_yes: "https://api.xmj123.top:8888/down/UjULjswxETmn.png",
          icon_no: "https://api.xmj123.top:8888/down/rQcl72z5vdWr.png",
        },
        {
          name: "文件夹",
          icon_yes: "https://api.xmj123.top:8888/down/2k0kelBqmw0I.png",
          icon_no: "https://api.xmj123.top:8888/down/yO3RzEGBni3k.png",
        },
        {
          name: "设置",
          icon_yes: "https://api.xmj123.top:8888/down/PzfTAVQaLCtW.png",
          icon_no: "https://api.xmj123.top:8888/down/H2WymGvtmBSJ.png",
        },
      ],
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      let _this = this;
      this.user = this.$store.state.info;
      let token = getToken();
      if (this.user.id == null) {
        getInfo(token).then(res => {
          if (res.code == 200) {
            _this.user = res.data;
            _this.$store.state.info = res.data;
          }
        });
      }
    },
    settingChoose(name) {
      this.$emit("settingChoose", name);
      this.settingChecked = name;
    },
  },
};
</script>

<style lang="less" scoped>
.myavatar {
  width: 50px;
  height: 80px;
  padding: 5px;

  img {
    margin-top: 30px;
    width: 40px;
    height: 40px;
  }
}

.setting::-webkit-scrollbar {
  display: none;
}
* {
  scrollbar-width: none;
}
.setting-list {
  width: 50px;
}

.setting-list-item {
  // background: red;
  width: 35px;
  height: 35px;
  padding: 12px;

  img {
    width: 35px;
    height: 35px;
  }
}
</style>
